package com.heyou.modules.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.heyou.common.service.impl.CrudServiceImpl;
import com.heyou.common.utils.Result;
import com.heyou.modules.member.dao.MemberDao;
import com.heyou.modules.member.dto.CouponDTO;
import com.heyou.modules.member.dto.MemberDTO;
import com.heyou.modules.member.entity.MemberEntity;
import com.heyou.modules.member.feign.ICouponFeignService;
import com.heyou.modules.member.service.MemberService;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 会员
 *
 * @author liangsw liangsw@yeah.net
 * @since 1.0.0 2025-05-22
 */
@Service
public class MemberServiceImpl extends CrudServiceImpl<MemberDao, MemberEntity, MemberDTO> implements MemberService {

    @Autowired
    private ICouponFeignService couponFeignService;

    @Override
    public QueryWrapper<MemberEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<MemberEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public Result<List<CouponDTO>> getMemberCoupon(Map<String, Object> params) {
        return couponFeignService.memberCoupons(params);
    }
}